package com.wanxi.dangdang.mapper;

import com.wanxi.dangdang.model.pojo.CUser;
import com.wanxi.dangdang.model.vo.CUserCheckVo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * @Author: WangRui
 * @Description:
 * @Date: Created in 2021/9/6 0006
 * @Version: 1.0
 */
public interface WeChatMapper {

    @Select("select id ,username,password,real_name,phone,picture from c_user where phone = #{account}")
    CUser findByAccount(@Param("account") String account);

    @Insert("insert into c_user (username,real_name,password,phone,picture,create_time,update_time)" +
            " value (#{username},#{realName},#{password},#{phone},#{picture},NOW(),NOW()) ")
    @Options(useGeneratedKeys=true, keyProperty="id" ,keyColumn = "id")
    void add(CUser cUser);
    @Select("select id, username,real_name,phone,picture from c_user where id = #{id}")
    CUser findById(@Param("id") Long id);

    @Select("select id, username,real_name,phone,picture from c_user where phone = #{account}")
    CUserCheckVo checkAccount(@Param("account") String account);
}
